var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var Person = /** @class */ (function () {
    function Person() {
    }
    //静态方法
    Person.sayHi = function () {
        console.log('hello world');
    };
    //静态类
    Person.uName = '夏天';
    return Person;
}());
//静态属性和静态方法的调用
Person.uName;
Person.sayHi();
//抽象类
//abstract 修饰
// 多态:父类定义一个方法不去实现，让继承它的子类去实现  每一个子类有不同的表现
var Animal = /** @class */ (function () {
    function Animal(aName) {
        this.aName = aName;
    }
    return Animal;
}());
var Dog = /** @class */ (function (_super) {
    __extends(Dog, _super);
    function Dog() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Dog.prototype.voice = function () {
        console.log(this.aName + ',汪汪');
    };
    return Dog;
}(Animal));
var Cat = /** @class */ (function (_super) {
    __extends(Cat, _super);
    function Cat() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Cat.prototype.voice = function () {
        console.log(this.aName + ',喵喵');
    };
    return Cat;
}(Animal));
// 先声明变量是Animal类型，具体是Dog还是Cat，在new 对象时才知道
//如果是Dog，Dog类中的voice方法；如果是Cat，Cat类中的voice方法，这就是多态！！
var animal;
animal = new Dog('小汪');
animal.voice();
animal = new Cat('小苗');
animal.voice();
//剩余参数
function info(x) {
    var args = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        args[_i - 1] = arguments[_i];
    }
    console.log(x);
    console.log(args);
}
info('小红', '小明', '小黑');
function add(x, y) {
    if (typeof x === 'string' && typeof y === 'string') {
        return x + y;
    }
    else if (typeof x === 'number' && typeof y === 'number') {
        return x + y;
    }
}
//调用函数
add('东方', '不败'); //东方不败
add(2, 2); //4
//使用泛型
function createArray(value, count) {
    var arr = [];
    for (var i = 0; i < count; i++) {
        arr.push(value);
    }
    return arr;
}
var strArr = createArray('哈', 3);
var numArr = createArray(1, 3);
console.log(strArr); //[ '哈', '哈', '哈' ]
console.log(numArr); // [ 1, 1, 1 ]
